<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== InArch ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 28.05.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class adminNodeFolder
    ****
    * This class handles the editing of folders
    ****
    * @package adminNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    * @since 28.05.2005
    * @copyright essentialmind.com 2005
    ***/
    class adminNodeTagCloud extends adminNode{
        
        /**
         * Processes all the user inputs!
         *
         */
        function process(){
            if($_POST){
            
                if($_POST['tag_type']){
                    $tag_type = (int)$_POST['tag_type'];
                }else{
                    $tag_type = 'NULL';
                }
            
                //update database record
                $this->db->Execute("UPDATE node_tag_cloud SET content = '".addslashes($_POST['content'])."', tag_type = $tag_type WHERE id = " . $this->object);
                
                //updates the status of the page (title, wf state)
                $this->updateNodeStatus();
                
                //make a note of the ajax request
                $this->log->recordAction("Updated TAG Cloud (".$this->object.") with global id (".$this->noderef.")");
            
                header('Location: '.$this->request.'&confirm=true');
                exit;
            }else{
                $this->smarty->assign('node',$this->db->getRow("SELECT 
                                                                    objectmap.title, 
                                                                    node_tag_cloud.* 
                                                                FROM objectmap
                                                                LEFT JOIN node_tag_cloud ON objectmap.objectid = node_tag_cloud.id 
                                                                WHERE version = 1 AND objectmap.nodeid = " . $this->noderef));
                                                                
                $this->smarty->assign('cTypes',$this->db->getAssoc("SELECT id, name FROM datatype WHERE folder = FALSE ORDER BY name"));
            }
        }
        
        
        /**
         * Sets the main template for the action
         *
         */
        function setTemplate(){
            $this->setActionTemplate('nodes/editTagCloud.html');
        }
        
        
        /**
         * Adds an instance to the data tree
         *
         * @return unknown
         */
        function addInstance(){
            $this->db->Execute("INSERT INTO node_tag_cloud(content) VALUES('')");
            return $this->db->getOne("SELECT last_value FROM node_tag_cloud_id_seq");
        }
    }
?>